
<%@ page import="com.surelution.projects.echo.domain.Blog" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'blog.label', default: 'Blog')}" />
        <title><g:message code="default.show.label" args="[entityName]" /></title>
        <script type="text/javascript">
			function changeStatus(status) {
				document.getElementById("blogStatus").value=status;
			}
        </script>
    </head>
    <body>
        <div class="nav" >
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
	        <sec:ifLoggedIn>
				<div   style='float: right'>
				当前用户：<sec:username />&nbsp;&nbsp;<g:link controller="user">修改密码</g:link>&nbsp;<g:link controller="logout">退出</g:link>
				</div>
       		</sec:ifLoggedIn>
       	</div>
        <div class="body">
            <h1><g:message code="default.show.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="dialog">
                <table>
                    <tbody>
                    
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="blog.title.label" default="Title" /></td>
                            
                            <td valign="top" class="value"><div>${fieldValue(bean: blogInstance, field: "title")}</div></td>
                            
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="blog.content.label" default="Content" /></td>
                            <td valign="top" class="value" width="100%">
                            <iframe src="../blogContent/${blogInstance.id}" style="border: 0;width: 100%"></iframe>
                            </td>
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="blog.createTime.label" default="Create Time" /></td>
                            <td valign="top" class="value"><div><g:formatDate date="${blogInstance.createTime}" format="yyyy年MM月dd日 HH点mm分"/></div></td>
                        </tr>
                    
                    </tbody>
                </table>
            </div>
            <div  class="table0">
            <div>
            	<table>
            		<g:each in="${comments}" var="comment" status="i">
            			<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
            				<td width="100%">
            					<table style="width:100%">
            						<tr>
			            				<td width="20%"><g:message code="comment.title.label" default="Content" /></td>
			            				<td width="80%"><b><font size="+1">${fieldValue(bean: comment, field: "title")}</font></b></td>
            						</tr>
            						<tr>
            							<td><g:message code="comment.content.label" default="Content" /></td>
            							<td>
            							<iframe src="../commentContent/${comment.id}" style="border: 0"></iframe>
            							</td>
            						</tr>
            						<tr>
            							<td>详细信息</td>
            							<td><font size="+1" color="blue">${fieldValue(bean: comment, field: "user.displayName")}</font>&nbsp;&nbsp;在&nbsp;&nbsp;<g:formatDate date="${comment.createTime}" format="yyyy年MM月dd日 HH点mm分"/>&nbsp;&nbsp;回复</td>
									</tr>
            					</table>
            				</td>
            			</tr>
            		</g:each>
            	</table>
            </div>
            <div class="buttons">
                <g:form>
                    <g:hiddenField name="id" value="${blogInstance?.id}" />
                    <g:hiddenField name="type" value="${blogInstance?.type}" id="blogStatus"/>
                    <sec:ifAllGranted roles="ROLE_ADMIN">
	                    &nbsp;&nbsp;当前：${fieldValue(bean: blogInstance, field: "typeDesc")}
	                    <g:if test="${blogInstance?.type!='READ'}"><span class="button"><g:actionSubmit class="edit" action="updateStatus" value="置为已读" onclick="changeStatus('READ')" /></span></g:if>
	                    <g:if test="${blogInstance?.type!='NEW'}"><span class="button"><g:actionSubmit class="edit" action="updateStatus" value="置为未读" onclick="changeStatus('NEW')" /></span></g:if>
	                    <g:if test="${blogInstance?.type!='OPEN'}"><span class="button"><g:actionSubmit class="edit" action="updateStatus" value="置为公开" onclick="changeStatus('OPEN')" /></span></g:if>
	                    <span class="button"><g:actionSubmit class="edit" action="comment" id="${blogInstance?.id}" value="${message(code: 'default.comment.label', default: 'Comment')}" /></span>
                        <span class="button">
                        	<g:actionSubmit class="delete" action="delete" id="${blogInstance?.id}" value="${message(code: 'default.delete.label', default: 'Del')}" onclick="return confirm('${message(code: 'default.delete.message', default: 'Are you sure to delete?')}');"/>
                        </span>
                    </sec:ifAllGranted>
                </g:form>
            </div>
           </div>
        </div>
    </body>
</html>
